package cn.qn.service.impl.sys;

import cn.qn.moudle.sys.Area;
import cn.qn.repository.sys.AreaRepository;
import cn.qn.service.sys.AreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Auther: Bryant
 * @Date: 2018/6/11
 * @Description:
 */
@com.alibaba.dubbo.config.annotation.Service(interfaceClass = AreaService.class)
@Service
public class AreaServiceImpl implements AreaService {

    @Autowired
    private AreaRepository areaRepository;

    @Override
    public List<Area> list(String cityCode) {
        return areaRepository.findByCityCodeOrderByCode(cityCode);
    }

    @Override
    public Area getArea(String areaCode) {
        return areaRepository.findByCode(areaCode);
    }

    @Override
    public List<Area> findAllAreas() {
        return areaRepository.findAll();
    }

    @Override
    public Area getAreaByName(String areaName) {
        return areaRepository.findAllByNameContaining(areaName);
    }
}
